package dormouse.vfs.ui;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Rectangle;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTabbedPane;
import javax.swing.JTextField;
import javax.swing.border.Border;
import javax.swing.border.TitledBorder;

import dormouse.vfs.ui.renderers.FileListTableBean;

/**
 * This class is responsible for displaying lists of files.
 */

public class FileListBean extends JPanel {
	
	/** Serial UID.*/
	private static final long serialVersionUID = 6157660768464970764L;
	
BorderLayout borderLayout1 = new BorderLayout();
  JSplitPane jSplitPane1 = new JSplitPane();
  JPanel jPanel1 = new JPanel();
  JScrollPane jScrollPane1 = new JScrollPane();
  FileListTableBean fileTable = new FileListTableBean();
  BorderLayout borderLayout2 = new BorderLayout();
  JPanel jPanel2 = new JPanel();
  JTabbedPane jTabbedPane1 = new JTabbedPane();
  BorderLayout borderLayout3 = new BorderLayout();
  JPanel fileNamePanel = new JPanel();
  JPanel datePanel = new JPanel();
  JLabel jLabel1 = new JLabel();
  JTextField startsWithFld = new JTextField();
  JLabel endsWithFld = new JLabel();
  JTextField startsWithFld1 = new JTextField();
  JLabel jLabel2 = new JLabel();
  JTextField regexFld = new JTextField();
  JLabel jLabel3 = new JLabel();
  JComboBox jComboBox1 = new JComboBox();
  JPanel jPanel5 = new JPanel();
  JButton jButton1 = new JButton();
  JButton jButton2 = new JButton();
  JButton jButton3 = new JButton();
  JLabel jLabel4 = new JLabel();
  JLabel jLabel5 = new JLabel();
  JPanel jPanel6 = new JPanel();
  Border border1;
  TitledBorder titledBorder1;
  JLabel jLabel6 = new JLabel();
  JLabel jLabel7 = new JLabel();
  JTextField startDateFld = new JTextField();
  JTextField endDateFld = new JTextField();
  JTextField createdBeforeFld = new JTextField();
  JTextField createdAfterFld = new JTextField();
  JDialog dialog = new JDialog();
  JPanel jPanel3 = new JPanel();
  JButton jButton4 = new JButton();
  JLabel jLabel8 = new JLabel();
  JComboBox jComboBox2 = new JComboBox();
  Container dialogCont = null;

  public FileListBean() {
	try {
	  jbInit();
	}
	catch(Exception ex) {
	  ex.printStackTrace();
	}
  }
  void jbInit() throws Exception {
	border1 = BorderFactory.createEtchedBorder(Color.white,new Color(178, 178, 178));
    titledBorder1 = new TitledBorder(border1,"Created Between");
    this.setLayout(borderLayout1);
	jSplitPane1.setOrientation(JSplitPane.VERTICAL_SPLIT);
	jSplitPane1.setDividerSize(8);
	jSplitPane1.setOneTouchExpandable(true);
	jPanel1.setLayout(borderLayout2);
	jScrollPane1.setMinimumSize(new Dimension(80, 80));
    jPanel2.setLayout(borderLayout3);
    jLabel1.setLabelFor(startsWithFld);
    jLabel1.setText("Starts With:");
    jLabel1.setBounds(new Rectangle(14, 12, 79, 16));
    fileNamePanel.setLayout(null);
    startsWithFld.setBounds(new Rectangle(97, 10, 170, 19));
    endsWithFld.setText("Ends With:");
    endsWithFld.setBounds(new Rectangle(15, 38, 74, 16));
    startsWithFld1.setBounds(new Rectangle(96, 34, 170, 19));
    jLabel2.setText("Regular Expression:");
    jLabel2.setBounds(new Rectangle(17, 75, 127, 16));
    regexFld.setBounds(new Rectangle(150, 75, 218, 19));
    jLabel3.setText("Regular Expression Type:");
    jLabel3.setBounds(new Rectangle(18, 106, 167, 16));
    jComboBox1.setBounds(new Rectangle(198, 101, 145, 25));
    jButton1.setText("Filter");
    jButton2.setText("Clear Filter");
    jButton3.setText("Save As VFolder");
    jLabel4.setText("Created Before:");
    jLabel4.setBounds(new Rectangle(17, 8, 108, 16));
    datePanel.setLayout(null);
    jLabel5.setText("Created After:");
    jLabel5.setBounds(new Rectangle(19, 30, 104, 16));
    jPanel6.setBorder(titledBorder1);
    jPanel6.setBounds(new Rectangle(13, 61, 354, 87));
    jPanel6.setLayout(null);
    jLabel6.setText("Start Date:");
    jLabel6.setBounds(new Rectangle(14, 27, 81, 16));
    jLabel7.setText("End Date:");
    jLabel7.setBounds(new Rectangle(15, 57, 73, 16));
    startDateFld.setBounds(new Rectangle(103, 25, 103, 19));
    endDateFld.setBounds(new Rectangle(103, 56, 103, 19));
    createdBeforeFld.setBounds(new Rectangle(124, 7, 101, 19));
    createdAfterFld.setBounds(new Rectangle(125, 35, 101, 19));
	jButton4.setBounds(new Rectangle(256, 5, 131, 26));
    jButton4.setText("New Filter...");
    jPanel3.setLayout(null);
    jPanel3.setPreferredSize(new Dimension(20, 30));
    jLabel8.setText("Use Filter:");
    jLabel8.setBounds(new Rectangle(6, 12, 71, 16));
    jComboBox2.setBounds(new Rectangle(77, 5, 145, 25));
    jSplitPane1.add(jPanel1, JSplitPane.TOP);
    jPanel1.add(jScrollPane1, BorderLayout.SOUTH);
    jSplitPane1.add(jPanel2, JSplitPane.BOTTOM);
    this.add(jPanel3, BorderLayout.NORTH);
    jPanel3.add(jLabel8, null);
    jPanel3.add(jButton4, null);
    jPanel3.add(jComboBox2, null);
    jScrollPane1.add(fileTable, null);
    jPanel6.add(jLabel6, null);
    jPanel6.add(jLabel7, null);
    jPanel6.add(startDateFld, null);
    jPanel6.add(endDateFld, null);
    datePanel.add(jLabel4, null);
    datePanel.add(jLabel5, null);
    datePanel.add(createdBeforeFld, null);
    datePanel.add(createdAfterFld, null);
    jTabbedPane1.add(datePanel, "Date");
    jTabbedPane1.add(fileNamePanel, "Filename");
    datePanel.add(jPanel6, null);
    fileNamePanel.add(jLabel1, null);
    fileNamePanel.add(startsWithFld, null);
    fileNamePanel.add(endsWithFld, null);
    fileNamePanel.add(startsWithFld1, null);
    fileNamePanel.add(jLabel2, null);
    fileNamePanel.add(regexFld, null);
    fileNamePanel.add(jLabel3, null);
    fileNamePanel.add(jComboBox1, null);

    //jPanel2.add(, BorderLayout.CENTER);
    jPanel5.add(jButton1, null);
    jPanel5.add(jButton2, null);
    jPanel5.add(jButton3, null);
    this.add(jSplitPane1, BorderLayout.CENTER);
	jSplitPane1.setDividerLocation(200);
    dialogCont = this.dialog.getContentPane();
    this.dialogCont.setLayout(new BorderLayout());
    this.dialogCont.add(jTabbedPane1, BorderLayout.CENTER);
    this.dialogCont.add(jPanel5, BorderLayout.SOUTH);
  }

  /**
   * This model initialises the FileListTableModel for the file table.
   * @param theModel
   */
  public void setModel(FileListTableModel theModel){
    this.fileTable.setModel(theModel);
  }
}